﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Web;
using System.Xml;

public static class WebUtil
{
    public static string SERVER_NODE = "VN_01";
    public static string LANGUAGE = "VN";
    public static string Command = "Command";
    public static string EMAIL = "EMAIL";
    public static string USERNAME = "Username";
    public static string TaoMaNgauNhien()
    {
        char[] captcha = {'1','2','3','4','5','6','7','8','9','0', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
				'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
				'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7',
				'8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
				'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
				'W', 'W', 'Y', 'Z' };
        string randomStr = "";
        int x;
        //That is to create the random # and add it to our string
        Random autoRand = new Random();
        for (x = 0; x < 6; x++)
        {
            int i = System.Convert.ToInt32(autoRand.Next(0, captcha.Length));
            randomStr += captcha[i].ToString();
        }
        return randomStr;
    }
    public static string CreateMD5(string Message)
    {
        MD5 MyMD5 = MD5.Create();
        byte[] HashCode = MyMD5.ComputeHash(Encoding.Unicode.GetBytes(Message));
        StringBuilder SB = new StringBuilder();
        for (int i = 0; i < HashCode.Length; i++)
            SB.Append(HashCode[i].ToString("x2"));
        return SB.ToString();
    }

    private static readonly string[] VietnameseSigns = new string[] 
    {
          "aAeEoOuUiIdDyY",
          "áàạảãâấầậẩẫăắằặẳẵ",
          "ÁÀẠẢÃÂẤẦẬẨẪĂẮẰẶẲẴ",
          "éèẹẻẽêếềệểễ",
          "ÉÈẸẺẼÊẾỀỆỂỄ",
          "óòọỏõôốồộổỗơớờợởỡ",
          "ÓÒỌỎÕÔỐỒỘỔỖƠỚỜỢỞỠ",
          "úùụủũưứừựửữ",
          "ÚÙỤỦŨƯỨỪỰỬỮ",
          "íìịỉĩ",
          "ÍÌỊỈĨ",
          "đ",
          "Đ",
          "ýỳỵỷỹ",
          "ÝỲỴỶỸ"
    };
    public static string RemoveSign4VietnameseString(string str)
    {

        for (int i = 1; i < VietnameseSigns.Length; i++)
        {
            for (int j = 0; j < VietnameseSigns[i].Length; j++)
                str = str.Replace(VietnameseSigns[i][j], VietnameseSigns[0][i - 1]);
        }
        return str;
    }

    public static class Page
    {
        public const int HOME = 0;
        public const int GOOGLE_MAP = 1;
        public const int ADD_PRODUCT = 2;
        public const int UPDATE_PRODUCT = 3;
        public const int PRODUCT_IN_STORE = 4;
        public const int HOME_USER = 5;
        public const int LOGIN = 6;
    }

}
